package com.stx.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.stx.pojo.Judge;
import com.stx.pojo.Params;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface JudgeMapper extends BaseMapper<Judge> {

    @Select("select * from r_judge;")
    List<Judge> selectjudge();

    @Select("select * from r_judge where jud_username=#{judUsername} limit 1")
    Judge findByName(@Param("judUsername") String judUsername);

    @Insert("insert into r_judge(id,jud_username,jud_password,jud_name,jud_role,jud_state,jud_date)"+
            "values(#{id},#{judUsername},#{judPassword},#{judName},#{judRole},#{judState},#{judDate})")
    void add(Judge judge);

    @Update("update r_judge set jud_username=#{judUsername},jud_password=#{judPassword},jud_name=#{judName},jud_role=#{judRole},jud_state=#{judState},jud_date=#{judDate} where id=#{id}")
    void updateID(Judge judge);

    @Delete("delete from r_judge where id=#{id}")
    void deleteID(Integer id);

    //@Select("select * from r_judge where jud_username=#{judUsername} and jud_password=#{judPassword} limit 1 ")
    @Select("select * from r_judge where jud_username=#{judUsername} limit 1 ")
    Judge findByNameAndPassword(Judge judge);

    @Select("select * from r_judge where r_judUsername=#{params.name} ")
    List<Judge> findBySearch(@Param("params") Params params);
}
